﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace medicine.DAL
{
    public static class OleDbUtilities
    {
        public static OleDbDataReader ExecuteDataReader(string SQL)
        {
            return ExecuteDataReader(DALUtilities.GetConnectionString(), SQL);
        }

        public static OleDbDataReader ExecuteDataReader(string ConnectionString, string SQL)
        {
            OleDbConnection cnn=new OleDbConnection(ConnectionString);
            OleDbCommand com= new OleDbCommand(SQL,cnn);
            cnn.Open();
            OleDbDataReader dr = com.ExecuteReader();
            return dr;
        }

        public static object ExecuteScalar(string SQL)
        {
            return ExecuteDataReader(DALUtilities.GetConnectionString(), SQL);
        }

        public static object ExecuteScalar(string ConnectionString, string SQL)
        {
            OleDbConnection cnn = new OleDbConnection(ConnectionString);
            OleDbCommand com = new OleDbCommand(SQL, cnn);
            cnn.Open();
            object value = com.ExecuteScalar();
            return value;
        }
    }
}
